import random
import matplotlib.pyplot as plt
#配置中文字体
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['Simhei']

#创建一个字典用于记录点数组合的次数
dice_counts = {}

#模拟投两个骰子100000次
for _ in range(100000):
    #随机生成两个随机数，模拟两个骰子的结果
    dice1_result = random.randint(1,6)
    dice2_result = random.randint(1,6)

    #计算点数组合
    total = dice1_result + dice2_result

    #将对应点数组合的计数加1
    if total in dice_counts:
        dice_counts[total] += 1
    else:
        dice_counts[total] = 1

#提取点数组合和对应的次数
totals = list(dice_counts.keys())
counts = list(dice_counts.values())
